﻿using System;

namespace enyo.db8
{
    [NonScript]
    public class Operations
    {
        [EvalAtCompile]
        public const string Allow = "allow";

        /// <summary>
        /// Set to "allow" to grant create permissions.
        /// </summary>
        public string Create;

        /// <summary>
        /// Set to "allow" to grant read permissions.
        /// </summary>
        public string Read;

        /// <summary>
        /// Set to "allow" to grant update permissions.
        /// </summary>
        public string Update;

        /// <summary>
        /// Set to "allow" to grant delete permissions.
        /// </summary>
        public string Delete;
    }

    public class Permission
    {
        /// <summary>
        /// Must be "db.kind"
        /// </summary>
        public string Type;

        /// <summary>
        /// db8 kind
        /// </summary>
        public string Object;

        /// <summary>
        /// ID of App or service being granted permissions.
        /// </summary>
        public string Caller;

        /// <summary>
        /// Operations you are allowing.
        /// </summary>
        public Operations Operations;
    }

    public class PutPermissionsParam : DbParam
    {
        public Permission[] Permissions;
    }
}
